﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ParseData
{
    /// <summary>
    ///For reading the sensors ID's.
    /// </summary>
    public class SensorFactory
    {
        public static ISensor createFromFile(string FileName) {
        string fileLine = "";
        string[] fileLines = FileReaderUtil.SplitFileByLine(FileName);

        // Sensor's ID
        int indexID = 1;

        // Parsing sensors ID
        fileLine = fileLines[indexID].Trim();
        String currentSensorID = fileLine.Substring(0, 6).Trim();
        int nrSensorID = Convert.ToInt32(currentSensorID);

        if ((nrSensorID >= 100000) && (nrSensorID < 200000))
            return new TempSensor(FileName);
        else if ((nrSensorID >= 200000) && (nrSensorID < 300000))
            return new LightSensor(FileName);
        else if ((nrSensorID >= 300000) && (nrSensorID < 400000))
            return new ECGSensor(FileName);
        else if ((nrSensorID >= 400000) && (nrSensorID < 500000))
            return new BPSensor(FileName);

        return null;
            
        }
    }
}
